package com.lanou.beautifulwardrobe.factory;

import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.lanou.beautifulwardrobe.home.OtherFragment;
import com.lanou.beautifulwardrobe.home.RecommendFragment;

/**
 * Created by dllo on 15/10/21.
 */
public class HomeFragmentFactory {
    private static SparseArray<Fragment> fragmentMap = new SparseArray<Fragment>();

    public static Fragment createFragment(int position,String itemIitle,String id) {
        Fragment f = fragmentMap.get(position);
        if (f == null) {
            switch (position) {
                case 0:
                    f = new RecommendFragment();
                    break;

                default:
                    f = new OtherFragment(itemIitle,id);
                    break;
            }
            fragmentMap.put(position,f);
        }
        return  f;
    }
}
